﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ITJZ.BitHelper.Local.UI.Component
{
    public partial class ucEditor : UserControl,IComponent.IEditorKnowledge
    {
        public ucEditor()
        {
            InitializeComponent();
        }



        #region IEditorKnowledge 成员

        ITJZ.BitHelper.APIModel.Knowledge _CurKnowledge=new ITJZ.BitHelper.APIModel.Knowledge ();
        public ITJZ.BitHelper.APIModel.Knowledge CurKnowledge
        {
            get { return _CurKnowledge; }
            set { _CurKnowledge = value; }
        }

        public event EventHandler Save;

        public event EventHandler Close;

        #endregion

        private void button1_Click(object sender, EventArgs e)
        {
            this.CurKnowledge.FullName = textBox1.Text;
            this.CurKnowledge.Content = richTextBox1.Rtf;

            //using (MemoryStream ms=new MemoryStream ())
            //{
            //    richTextBox1.SaveFile(ms, RichTextBoxStreamType.RichText);
            //    ms.Position = 0L;
            //    TextReader reader = new StreamReader(ms);
            //   this.CurKnowledge.Content = reader.ReadToEnd();
            //}
            Save(this, new EventArgs());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close(this, new EventArgs());
        }
    }
}
